<h2>Database Table class</h2>

<p>The Database Table class is very powerful. You can easily setup a Table Model
and use it in your controllers.</p>

<hr />

<h3>Finding rows</h3>
<p>To find a row by its primary key, you can use the find() method. Create a
new instance of your Table Model which extends the System Database Table. See
below for an example:</p>
<pre>
namespace application\models;

use system\libraries\database\Table;

class UsersTable extends Table
{
&nbsp;&nbsp;&nbsp;protected $_name    = 'users';
&nbsp;&nbsp;&nbsp;protected $_primary = 'id';
}
</pre>

<p>This is all you have to do! Easy, isn't it? Well, how do we use this in our 
controllers? Let's look at the next example:</p>

<pre>
namespace application\controllers;

use system\core\Controller;
use application\models\UsersTable;

class Users extends Controller
{
&nbsp;&nbsp;&nbsp;&nbsp;public function show( $id = NULL )
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$usersTable = new UsersTable();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$data['user'] = $usersTable->find($id);
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->load->vars($data);
&nbsp;&nbsp;&nbsp;&nbsp;}
}
</pre>

<p>First we namespace our controller, then we define which classes we gonna use
in our controller. Then we create the actual controller with the method show().
Within this method we create a new instance of our UsersTable model. We want 
to get all the data related to the given id (see parameter of this method). So
we call the find() method! It will fetch the row related to the given id. And 
then of course, we wanna load the $data variable to the Registry.</p>